import brightness from '@blueos.hardware.display.brightness'
import prompt from '@blueos.window.prompt'

export const showToast = (message) => {
  prompt.showToast({
    message,
  })
}

export const setKeepScreenOn = () => {
  brightness.setKeepScreenOn({
    // @ts-ignore
    keepScreenOn: true,
    success: function () {},
    fail: function (data, code) {
      console.log(`handling fail, code = ${code}`)
    },
  })
}


export const setKeepScreenOff = () => {
  brightness.setKeepScreenOn({
    // @ts-ignore
    keepScreenOn: false,
    success: function () {},
    fail: function (data, code) {
      console.log(`handling fail, code = ${code}`)
    },
  })
}

// 菜单排序
export const sortMeaus = (list) => {
  return list.sort((a, b) => {
    return b.level - a.level
  })
}